﻿using HDSmartCommunity.DevicePlatform;
using HDSmartCommunity.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Threading.Tasks;

namespace HDSmartCommunity.BUS
{
    public class DeviceBUS
    {
        public string PingTest(string ip)
        {
            Ping ping = new Ping();
            PingReply pingReply = ping.Send(ip);
            string replay;
            if (pingReply.Status == IPStatus.Success)
            {
                replay = "当前在线，已ping通！";
            }
            else
            {
                replay = "不在线，ping不通！";
            }
            return replay;
        }

        public List<KoneInfo> QueryAllKoneDevice()
        {
            List<KoneInfo> koneDeviceInfos = new List<KoneInfo>();
            try
            {
                List<KoneDeviceInfo> list =KoneVoltageSerialData.kone_list;
                foreach (var item in list)
                {
                    KoneInfo koneInfo = new KoneInfo();
                    koneInfo.DeviceName = item.DeviceName;
                    koneDeviceInfos.Add(koneInfo);
                }
            }
            catch
            {

            }
            return koneDeviceInfos;
        }
    }
}
